function timer(callback, delay) {
    var id, started, remaining = delay, running

    this.start = function() {
        running = true
        started = new Date()
        id = setTimeout(callback, remaining)
    }

    this.pause = function() {
        running = false
        clearTimeout(id)
        remaining -= new Date() - started
    }

    this.getTimeLeft = function() {
        if (running) {
            this.pause()
            this.start()
        }

        return remaining
    }

    this.getStateRunning = function() {
        return running
    }

    this.start()
}

// a = new timer(function() {
//     // What ever
//     console.log(" What ever ");

// }, 1000)

// var startData = new Date()

// setTimeout(function() {
//     console.log(new Date('2017-5-25') - startData)
// }, 5 * 1000);


// item = []
// var test = item[-1]
// console.log(test) 

// var onTimeFinished = function (arg) {
//     console.log("timer finied", arg);
// }
// setTimeout(onTimeFinished, 1 * 1000, 1);

// var starData = new Date();
// console.log(starData);

// 参考 ：
// http://www.w3school.com.cn/jsref/jsref_obj_date.asp
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

var newData = new Date()

console.log(newData);
console.log(newData.getFullYear()); 
console.log(newData.getMonth()); //start from 0
console.log(newData.getDay()); 


// 2017-05-03T14:26:01.956Z
// 2017
// 4
// 3

//add one day
newData.setTime(newData.getTime() + 1 * 24 * 60 * 60 * 1000); 
console.log(newData);

var testday1  = new Date('December 25, 1995 23:15:30');
function  judgeSame(day1, day2) {
    return day1.getFullYear() == day2.getFullYear() &&  day1.getMonth() == day2.getMonth() && day1.getDay() == day2.getDay();
}
console.log(judgeSame(testday1, newData)); 
console.log(testday1 < newData)


//get 公元元年
console.log(new Date(0));

// var span = newData.getSeconds() - starData.getSeconds()
// console.log(span)

// 
// var month = Xmas95.getMonth();
